package com.dayuanit.mall.bank.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.dayuanit.mall.bank.exception.MallBusException;

public class DateUtil {
	
	public static final String PATTERN_YYYYMMDDHHMMSS = "yyyyMMddhhmmss";
	
	public static String dateToString(Date date, String pattern) {
		return new SimpleDateFormat(pattern).format(date);
	}
	
	public static Date stringToDate(String date, String pattern) {
		try {
			return new SimpleDateFormat(pattern).parse(date);
		} catch (ParseException e) {
			throw new MallBusException("时间格式化失败");
		}
	}

}
